﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using VietThinks.Contract;

namespace VietThinks.Website
{
    public partial class VisitContext
    {
        public class TransactionManager
        {
            private TransactionManager() { }

            private static readonly TransactionManager instance = new TransactionManager();

            internal static TransactionManager Instance
            {
                get { return instance; }
            }

            public string CreateSessionId()
            {
                var service = ServiceProvider.GetService<ISecurityService>();

                return string.Format("{0}{1}", ApplicationSettingsManager.Current.ServerType, service.GenerateRandomString(6, CharSets.Numerics));
            }

            public string CreateTransactionId()
            {
                return string.Format("1{0}{1}", DateTime.Now.ToString("yyMMdd"), VisitContext.OmnitureSessionId);
            }

        }
    }
}